using System;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Xsl;
using Microsoft.BizTalk.TestTools.Mapper;
using Microsoft.BizTalk.TestTools.Schema;

namespace MapTestFramework.Common
{
	/// <summary>
    /// Represents a map executer that transforms XML instances using a BizTalk map represented by a TestableMapBaseMapExecuter class.
    /// </summary>
	public class TestableMapBaseMapExecuter : IMapExecuter
    {
        #region Constructor And Initializing Members

        /// <summary>
        /// Initializes a new instance of the TestableMapBaseMapExecuter class with the specified map.
        /// </summary>
        /// <param name="map">Map instance.</param>
        [CLSCompliant(false)]
        public TestableMapBaseMapExecuter(TestableMapBase map)
        {
            if (map == null)
                throw new ArgumentNullException("map");

            m_Map = map;
            return;
        }

        #endregion

        #region IMapExecuter Members

        public void ExecuteMap(string sourcePath, string targetPath)
        {
            ExceptionHelper.CheckEmptyOrNullValue(sourcePath, "sourcePath");
            ExceptionHelper.CheckEmptyOrNullValue(targetPath, "targetPath");

            this.Map.TestMap(sourcePath, InputInstanceType.Xml, targetPath, OutputInstanceType.XML);
            return;
        }

        #endregion

        #region Helper Members

        private TestableMapBase m_Map;

        private TestableMapBase Map
        {
            get { return m_Map; }
        }

        #endregion
    }
}
